package com.awifi.spring;

import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//http://localhost:8080/mvc-xml/test

@Controller
public class RequestResponseExampleController {
	
	@RequestMapping("/test")
	@ResponseBody
	public void requestResponseExample( HttpServletRequest request,
										  HttpServletResponse response,
										  Model model ){
		String result="";
		result += "method:" + request.getMethod() + "  uri:" + request.getRequestURI()+
		"  url:" + request.getRequestURL();
		try {
			ServletOutputStream outputStream = response.getOutputStream();
			outputStream.println(result);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return;
	}
}
